﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.DBM;
using System.Globalization; 

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class WF_FinanceInfo : System.Web.UI.UserControl
    {


        private object _dataItem = null;





        protected bool IsUserControlPostBack
        {
            get
            {
                return this.ViewState["IsUserControlPostBack"] != null;
            }
        }


        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);

            if (!IsUserControlPostBack)
            {


                this.ViewState.Add("IsUserControlPostBack", true);

            }



            if (DataItem != null)
            {
               


                if (!(DataItem is Telerik.Web.UI.GridInsertionObject))
                {

                    lblFinanceSeq.Text = DataBinder.Eval(DataItem, "finance_seq").ToString();
                    txtName.Text = DataBinder.Eval(DataItem, "finance_name").ToString();
                    txtRemarks.Text = DataBinder.Eval(DataItem, "remarks").ToString();
                    
                 
                }


                btnUpdate.Visible = !(DataItem is Telerik.Web.UI.GridInsertionObject);
                btnAddnew.Visible = (DataItem is Telerik.Web.UI.GridInsertionObject);
            }

           }



        protected void Page_Load(object sender, EventArgs e)
        {

            
        }

 

        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }

     


       

        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            WelfareFinanceBLL obj = new WelfareFinanceBLL();
            string finance_name, remarks;
            finance_name = txtName.Text; 
          //  int finance_seq = int.Parse(Session["finance_seq"].ToString());
         
            if (obj.chkDupFinance(finance_name) == true)
            {
                        return;
             }
         
           

            finance_name = txtName.Text;
            remarks= txtRemarks.Text;
            obj.insert(finance_name, remarks, 1);   
         
           

        }


        protected void btnUpdate_Click(object sender, EventArgs e)
        {

            WelfareFinanceBLL obj = new WelfareFinanceBLL();

            string finance_name, remarks;
            int finance_seq;
            finance_seq = int.Parse(lblFinanceSeq.Text);
    
            finance_name = txtName.Text;




            if (obj.chkDupFinanceEdit(finance_name,finance_seq) == true)
            {
                return;
            }

            remarks = txtRemarks.Text;
            obj.Update(finance_seq, finance_name, remarks, 1);   


        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }


        protected void txtName_TextChanged(object sender, EventArgs e)
        {

        }

        protected void txtRemarks_TextChanged(object sender, EventArgs e)
        {

        }


    }
}
        